<template>
    <div>
        <div class="topsubmint el-col el-col-21">理赔结果
    
            <el-button type="primary" style="float:right" @click="onSubmit">导出excle</el-button>
        </div>
        <el-card class="box-card">
            <div slot="header" class="card-heaer">
                <span style="line-height: 36px;">理赔结果</span>
    
            </div>
    
            <div v-for="(da,daindex) in results " :key="daindex">
                <el-form :inline="true" class="demo-form-inline">
                    <el-form-item label="总花费：">
                        ${{da.RESULT_ALLMONEY}}
                    </el-form-item>
                    <el-form-item label="用户实际花费：">
                        ${{da.RESULT_USERMONEY}}
                    </el-form-item>
                     <el-form-item label="用户自付比例金额：">
                        ${{da.RESULT_ZFBLMONEY}}
                    </el-form-item>
                    <el-form-item label="保险公司支付：">
                        ${{da.RESULT_PAYMONEY}}
                    </el-form-item>
                     <el-form-item label="输入汇率：">
                        {{da.RESULT_LV}}
                    </el-form-item>                 
                   
                </el-form>
    
            </div>
    
            <el-collapse v-if="length()">
                <el-collapse-item :title="data.BILL_DATA_DATA+'账单'" :key="data.BILL_DATA_DATA" v-for="(data, index) in bill ">
    
                    <el-card class="box-card">
                        <div slot="header" class="card-heaer">
                            <span style="line-height: 36px;">{{data.BILL_DATA_DATA}}账单</span>
    
                        </div>
                        <el-form label-width="100px">
                            <el-row type="flex" class="row-bg">
                               
                                <el-form-item label="医院类型:">
                                    <el-radio-group v-model="data.BILL_DATA_TYPE" :disabled="true">
                                        <el-radio label="网络内"></el-radio>
                                        <el-radio label="网络外"></el-radio>
                                    </el-radio-group>
                                </el-form-item>
    
                            </el-row>
                        </el-form>
                        <div class="space20">
                        </div>
                        <div v-for="(de,deindex) in getresult(data.BILL_DATA_DATA)" :key="deindex">
                            <el-form :inline="true" class="demo-form-inline">
                                <el-form-item label="总花费：">
                                    ${{de.RESULT_DUTY_ALLMONEY}}
                                </el-form-item>
                                <el-form-item label="用户实际花费：">
                                    ${{de.RESULT_DUTY_USERMONEY}}
                                </el-form-item>
                                 <el-form-item label="用户自付比例金额：">
                                    ${{de.RESULT_DUTY_ZFBLMONEY}}
                                </el-form-item>
                                <el-form-item label="保险公司支付：">
                                    ${{de.RESULT_DUTY_PAYMONEY}}
                                </el-form-item>
    
                             
                            </el-form>
    
                        </div>
                        <lipeicheck_item :billdataid="index" :islipei="true" ref="dataform" :detail="getresult(data.BILL_DATA_DATA)">
                        </lipeicheck_item>
                    </el-card>
                </el-collapse-item>
            </el-collapse>    
           
        </el-card>
    </div>
</template>
<script>
import {
    mapState
} from 'vuex';
import getid from '@/js/getid';
import lipeicheck_item from '@/components/lipei/jisuan_item';
export default {
    data() {
        return {
            results: []

        };
    },

    components: {
        'lipeicheck_item': lipeicheck_item
    },
    computed: mapState({
        bill: state => state.bill.bill

    }),

    methods: {
        getresult(data) {
            var arry = [];
            for (var i = 0; i < this.results[0].RESULT_DUTY.length; i++) {
                if (this.results[0].RESULT_DUTY[i].RESULT_DUTY_DATE == data) {
                    arry.push(this.results[0].RESULT_DUTY[i]);
                }
            }
            return arry;
        },
        length() {
            if (this.bill.length > 0) {
                for (var i = 0; i < this.bill.length; i++) {
                    var detail = this.bill[i].BILL_DATA_DETAIL;
                    var detlength = 0;
                    for (var k = 0; k < detail.length; k++) {
                        if (detail[k].BILL_DATA_DETAIL_STATE != "删除") {
                            detlength++;
                        }
                        if (k == detail.length - 1 && detlength == 0) {
                            return false;
                        }
                    }
                    if (i == this.bill.length - 1) {
                        return true;
                    }
                }
            } else {
                return false;
            }
        },
        onSubmit() {
            this.$http.get("File/" + this.$route.query["id"]).then(response => {
                var data = response.body;
                if (data.code == 1) {
                    var url = this.$http.options.root;
                    var base = url.substring(0, url.length - 3);
                    window.open(base + data.msg);
                }
            }, response => {
                this.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
            })


        },

    },
    activated() {
        this.bill.splice(0, this.bill.length);
        this.$http.get("Bill/GetResult?state=计算完成&id=" + this.$route.query["id"]).then(response => {
            var data = response.body;
            if (data.code == 1) {
                //更新
                this.$store.commit('changer', data.result[0].BILL_DATA)


                this.results = data.result[0].RESULTs;

                this.BILL_DISEASE = data.result[0].BILL_DISEASE;
                this.BILL_DISEASEDETAIL = data.result[0].BILL_DISEASEDETAIL;
            } else {

            }

        }, response => {
            this.$notify.error({
                title: '网络错误',
                message: '网络错误'
            });
            this.loding = false;
        });


    }

}
</script>